﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Login
{
    public partial class LoginPage : SessionManager
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string userName = SessionManager.GetUserName(Context);
            string password = SessionManager.GetPassword(Context);
            Login_Dialog.UserName = userName;
            // Login_Dialog.Password = password;

            Do(userName, password);

        }

        protected void Login_Authen(object sender, AuthenticateEventArgs e)
        {
            string user_name;
            string password;

            user_name = Login_Dialog.UserName;
            password = Login_Dialog.Password;
            if ((user_name == "Kien") && (password == "1234"))
            {
                Session[Constants.USER_NAME] = user_name;
                Session[Constants.PASSWORD] = password;
                Response.Redirect("MaterialList.aspx");

            }
            else {
                Login_Dialog.UserName = "abc";
            }
        }

        protected void Do(string username, string password)
        {
            if ((username == "Kien") && (password == "1234"))
            {
                Session[Constants.USER_NAME] = username;
                Session[Constants.PASSWORD] = password;
                Response.Redirect("MaterialList.aspx");

            }
            else
            {
                Login_Dialog.UserName = "abc";
            }
        }

    }
}
